<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/26
 * Time: 14:24
 */

namespace App;


use Illuminate\Database\Eloquent\Model;

class DynamicComment extends Model
{
    // 状态正常
    const ONLINE = 1;
    // 被隐藏
    const OFFLINE = 0;
    // 表名称
    protected $table = 'dynamic_comment';
    // 开启自动时间戳
    public $timestamps = true;
    // 日期都存储为时间戳
    protected $dateFormat = 'U';

    public function user()
    {
        return $this->belongsTo('App\Users', 'user_id', 'id');
    }

    public function dynamicComment()
    {
        return $this->hasMany('App\DynamicComment', 'parent_id', 'id')->with(['user', 'reUser']);
    }

    public function reUser()
    {
        return $this->belongsTo('App\Users', 're_user_id', 'id');
    }

    public function dynamic()
    {
        return $this->belongsTo('App\Dynamic', 'dynamic_id', 'id');
    }
}